package com.dragon.pear.modules.trade.service.assistants.converters;

import java.sql.Timestamp;
import com.dragon.common.base.utils.ConvertUtil;
import com.dragon.common.base.utils.DbUtil;
import com.dragon.common.spring.annotations.DataConverter;
import com.dragon.common.spring.business.base.BaseConverter;
import com.dragon.utils.TimeUtil;
import com.dragon.pear.modules.trade.domain.entity.TradeGoodsCategoryEntity;
import com.dragon.pear.modules.trade.web.model.params.create.TradeGoodsCategoryCreateParam;
import com.dragon.pear.modules.trade.web.model.params.update.TradeGoodsCategoryUpdateParam;
import com.dragon.pear.modules.trade.web.model.results.TradeGoodsCategoryResult;

/**
 * @author Chris Chan
 * Create on 2025-09-30 22:06
 * Use for: 商品分类 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class TradeGoodsCategoryConverter implements BaseConverter<
        TradeGoodsCategoryEntity,
        TradeGoodsCategoryCreateParam,
        TradeGoodsCategoryUpdateParam,
        TradeGoodsCategoryResult> {
    @Override
    public TradeGoodsCategoryEntity fromParam(TradeGoodsCategoryCreateParam param) {
        TradeGoodsCategoryEntity entity = new TradeGoodsCategoryEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public TradeGoodsCategoryEntity fromUpdateParam(TradeGoodsCategoryUpdateParam param) {
        TradeGoodsCategoryEntity entity = ConvertUtil.convert(param, TradeGoodsCategoryEntity.class);
        return entity;
    }

    @Override
    public TradeGoodsCategoryResult toResult(TradeGoodsCategoryEntity entity) {
        TradeGoodsCategoryResult result = ConvertUtil.convert(entity,TradeGoodsCategoryResult.class);
        return result;
    }
}